package main;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;

import control.Button;
import control.ControlCommand;

public class PauseCanvas extends GameCanvas {
	protected Button[] listButton;
	protected final MainMidlet game;
	//protected Image background;

	protected PauseCanvas(MainMidlet midlet) {
		super(true);
		this.game = midlet;
		setFullScreenMode(true);

		int sW = getWidth();
		int bW = 155;
		listButton = new Button[3];

		listButton[0] = new Button(Res.IMG_BUTTON, bW, 40, (sW - bW) / 2, 140,
				"RESUME");
		listButton[0].setCommand(new ControlCommand() {
			public void Do() {
				game.showPlayingCanvas();
			}
		});

		listButton[1] = new Button(Res.IMG_BUTTON, bW, 40, (sW - bW) / 2, 180,
				"MAIN MENU");
		listButton[1].setCommand(new ControlCommand() {
			public void Do() {
				PlayingCanvas.getInstance().stop();
				game.showMenuCanvas();
			}
		});

		listButton[2] = new Button(Res.IMG_BUTTON, bW, 40, (sW - bW) / 2, 220,
				"EXIT");
		listButton[2].setCommand(new ControlCommand() {
			public void Do() {
				game.destroyApp(false);
				game.notifyDestroyed();
			}
		});
	}

	protected void pointerPressed(int x, int y) {
		for (int i = 0; i < listButton.length; i++) {
			listButton[i].pointerPressed(x, y);
		}
		repaint();
	}

	protected void pointerReleased(int x, int y) {
		for (int i = 0; i < listButton.length; i++) {
			listButton[i].pointerReleased(x, y);
		}
		repaint();
	}

	protected void pointerDragged(int x, int y) {
		for (int i = 0; i < listButton.length; i++) {
			listButton[i].pointerPressed(x, y);
		}
		repaint();
	}

	public void paint(Graphics g) {
		g.setColor(0x886600);
		g.fillRect(0, 0, 240, 400);
		for (int i = 0; i < listButton.length; i++) {
			listButton[i].paint(g);
		}
	}
}
